﻿var Store = {
    version: '1.0.0.0.0',
    All: 0,
    Import: 1,
    Delivery: 2,

    ListByType: function (ddlArea, typeId, selected, event) {                
        var url = String.format('/GetRequest.ashx?m=store&action=listbytype&tId={0}&rand={1}', typeId, Math.random());
        $.getJSON(url, function (res) {
            if (res.Success) {                
                var html = '';
                html += String.format('<select style="width: 110px" {0}>', event);

                if (res.Data.length > 0) {
                    $.each(res.Data, function (i, val) {
                        if (selected > 0 && val.StoreId == selected)
                            html += String.format('<option value="{0}" selected="selected">{1}</option>', val.StoreId, val.Name);
                        else
                            html += String.format('<option value="{0}">{1}</option>', val.StoreId, val.Name);
                    });
                }
                
                html += '</select>';

                $(ddlArea).html(html);
                $('form').jqTransform();                
            }
        });        
    }
};
    